const { viewNameFormat, getViews, getLayouts } = require("./utils");
exports.routeExists = (value) => {
	if (!value) {
		return "输入为空"
	}
	const routes = Object.keys(getViews());
	const compared = viewNameFormat(value);
	for (let route of routes) {
		if (compared === viewNameFormat(route)) {
			return "存在重名页面(view)，请更换名称"
		}
	}
	const layouts = Object.keys(getLayouts());
	for (let route of layouts) {
		if (compared === viewNameFormat(route)) {
			return "存在重名布局（layout），请更换名称"
		}
	}
	return true
}

exports.notEmpty = (v) => {
	return !v || v.trim() === '' ? `输入不能为空` : true
}